local hx__dedao = fk.CreateSkill {
  name = "hx__dedao",
  tags = { Skill.Limited },
}

hx__dedao:addEffect("active", {
  name = "hx__dedao",
  card_num = 1,
  target_num = 1,
  can_use = function(self, player)
    return player:usedSkillTimes(hx__dedao.name, Player.HistoryGame) == 0 and not player:isKongcheng()
  end,
  card_filter = function(self, player, to_select, selected)
    return #selected == 0 and not player:prohibitDiscard(Fk:getCardById(to_select))
  end,
  target_filter = function(self, player, to_select, selected)
    return #selected == 0
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local to = effect.tos[1]
    room:throwCard(effect.cards, hx__dedao.name, player, player)
    if player.dead then return end
    local card = Fk:getCardById(effect.cards[1])
    local x = card.number
    local y = player:getMark("@hx__xianbian")
    room:drawCards(to, x, hx__dedao.name)
    room:recover({
      who = player,
      num = y,
      skillName = hx__dedao.name
    })
    room:setPlayerMark(player,"@hx__xianbian",0)
    room:setPlayerMark(player,"@@hx__xianbian_b",0)
    room:setPlayerMark(player,"@@hx__xianbian_t",0)
    room:setPlayerMark(player,"@@hx__xianbian_e",0)
    room:handleAddLoseSkills(player,"-hx__xianbian")
  end,
})

return hx__dedao